package top.xylweb.user.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.xylweb.common.utils.SecurityUtils;
import top.xylweb.user.dao.UserMapper;
import top.xylweb.user.entity.User;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@Service("userServiceImp")
public class UserServiceImp implements UserService {


    @Autowired
    private UserMapper userMapper;

    /**
     * @Author X [**.**.**]
     * @Date 2017/12/17 15:28
     * Description  查询用户
     **/
    @Override
    public User findUserBuUserName(String username) {
        User user =  userMapper.selectByUserName(username);
        return user;
    }

    /**
     * @Author X [**.**.**]
     * @Date 2017/12/17 15:43
     * Description 注册 创建用户
     **/
    @Override
    public void createUser(User user) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
        userMapper.insertSelective(user);
    }

    @Override
    public User findUserByUserName(String username) {
        return null;
    }
}
